#include <iostream>
using std::cout;
using std::endl;
//访问冲突二义性
class A{
public:
    A(){
        cout << "A()" << endl;
    }
    ~A(){
        cout << "~A()" << endl;
    }
    void print(){
        cout << "A::print" << endl;
    }
private:
    int _a = 10;
};
class B{
public:
    B(){
        cout << "B()" << endl;
    }
    ~B(){
        cout << "~B()" << endl;
    }

    void print(){
        cout << "print" << endl;
    }
private:
    int _b = 20;
};
class C{
public:
    C(){
        cout << "C()" << endl;
    }
    ~C(){
        cout << "~C()" << endl;
    }
    void print(){
        cout << "print" << endl;
    }
private:
    int _c = 30;
};
//表示的是公有继承A、B、C
//在这种继承关系下，那么D对象的创建和销毁时如何的
//对应的内存布局是什么样的？？？
class D: 
    public A,
    public B,
    public C{
public:
    D(){
        cout << "D()" << endl;
    }
    ~D(){
        cout << "~D()" << endl;
    }

    void print(){
        cout << "D::print()" << endl;
    }
private:
    int _d = 40;
};
void test(){
    D d;
    //因为在A B C中均有该同名的成员函数
    //所以此时会出现访问的二义性
    //d.print();error
    d.A::print();
    d.print();
}


int main()
{
    test();
    return 0;
}

